let rec exist p  = function
  [] -> false
  |e::l -> if p=e then
                  true
           else 
           exist p l;;

let rec add_list x = function 
  [] -> x::[]
  |e::l -> if e<x then  
               e::add_list x l 
        
           else if x=e then 
                           e::l
                else  
                    x::e::l ;;



let rec remove_list x = function 
[] -> []
  |e::l -> if e<x then 
                  e::remove_list x l 
           else if e=x then remove_list x l
           else e::l;;  


let rec map f list = match list with
[] -> []
  |e::l -> (f e)::(map f l);;



let rec iter f = function
[] -> ()
  |e::l -> (f e ; (iter f l));;




let rec for_all p = function 
[] -> true 
  |e::l -> if p e then for_all p l 
           else 
           false;; 




               
let upper_case  = function x -> if  (int_of_char x ) >= 97 && (int_of_char x ) <= 122 then  
                                                                char_of_int((int_of_char
                                                                x )-32) else x 


let lower_case = function x -> if (int_of_char x ) >= 65 && (int_of_char x ) <= 90 then 
                                                                                   char_of_int((int_of_char
                                                                                   x
)+32) else x 

let string_of_char c = String.make 1 c ;;

let string_apply f chaine = 
  let rec parse i newchaine = match i with  
     n when n = (String.length chaine) - 1 ->  newchaine^(string_of_char (f chaine.[n]))
    |i -> parse (i+1) (newchaine^(string_of_char (f chaine.[i])))
  in parse 0 "";;



let string_uppercase chaine  = string_apply  upper_case chaine;; 

let string_lowercase chaine = string_apply  lower_case chaine ;;

let convert_first_maj c =
  let x = 1 and length = String.length c in
    let rec read x =
      match x with
        x when x < length -> string_of_char ((c.[x])) ^ read (x+1)
		|_                -> ""
	in string_of_char ((upper_case c.[0])) ^ string_lowercase(read x);;



let create_contact(name,age,adress,telephone)  =(convert_first_maj (name),age,adress,telephone);;

